# # -*- coding: utf-8 -*-
# from datetime import timedelta
# from time import time
# from utils.operators.rich_sql_sensor import RichSqlSensor
# from jms.ods.oms.yl_oms_oms_waybill import jms_ods__yl_oms_oms_waybill
#
# label = f"yl_oms_oms_waybill_{int(time())}"
# timeout = timedelta(hours=10).seconds
# doris_jms_ods__yl_oms_oms_waybill = RichSqlSensor(
#     task_id='doris_jms_ods__yl_oms_oms_waybill',
#     pool='broker_load_pool',
#     email=['lukunming@jtexpress.com','yl_bigdata@yl-scm.com'],
#     task_concurrency=1,
#     conn_id='new_doris',
#     pre_sql=f"""
#                  LOAD LABEL jms_ods.{label} (
#                      DATA INFILE("hdfs://yl-bg-hdp/dw/hive/jms_ods.db/external/yl_oms_oms_waybill/dt={{{{ execution_date | cst_ds }}}}/*")
#                      INTO TABLE yl_oms_oms_waybill
#                      FORMAT AS 'PARQUET'
#                         (
#                         id
#                         ,waybill_no
#                         ,waybill_status_code
#                         ,goods_type_id
#                         ,goods_type_code
#                         ,goods_type_name
#                         ,goods_name
#                         ,package_number
#                         ,package_length
#                         ,package_wide
#                         ,package_high
#                         ,package_volume
#                         ,package_total_weight
#                         ,package_total_volume
#                         ,package_charge_weight
#                         ,box_standard_code
#                         ,box_standard_name
#                         ,box_number
#                         ,box_price
#                         ,collect_staff_code
#                         ,collect_staff_name
#                         ,collect_time
#                         ,dispatch_staff_code
#                         ,dispatch_staff_name
#                         ,dispatch_time
#                         ,dispatch_network_id
#                         ,dispatch_network_code
#                         ,dispatch_network_name
#                         ,exception_code
#                         ,exception_reason
#                         ,terminal_dispatch_code
#                         ,is_sign
#                         ,sign_network_id
#                         ,sign_network_code
#                         ,sign_network_name
#                         ,sign_finance_code
#                         ,sign_finance_name
#                         ,sign_time
#                         ,is_real_name
#                         ,is_abnormal
#                         ,abnormal_reg_network_code
#                         ,abnormal_reg_network_name
#                         ,abnormal_reg_time
#                         ,order_id
#                         ,customer_order_id
#                         ,waybill_source_code
#                         ,waybill_source_name
#                         ,send_code
#                         ,send_name
#                         ,dispatch_code
#                         ,dispatch_name
#                         ,is_void
#                         ,is_refund
#                         ,is_need_receipt
#                         ,receipt_no
#                         ,is_settlement
#                         ,settlement_time
#                         ,customer_code
#                         ,customer_name
#                         ,sender_name
#                         ,sender_country_id
#                         ,sender_country_name
#                         ,sender_province_id
#                         ,sender_province_name
#                         ,sender_city_id
#                         ,sender_city_name
#                         ,sender_area_id
#                         ,sender_area_name
#                         ,sender_township
#                         ,sender_street
#                         ,sender_detailed_address
#                         ,sender_postal_code
#                         ,sender_email
#                         ,origin_id
#                         ,origin_code
#                         ,origin_name
#                         ,pick_network_id
#                         ,pick_network_code
#                         ,pick_network_name
#                         ,freight
#                         ,package_cost
#                         ,total_freight
#                         ,tax
#                         ,handicraft_fee
#                         ,other_fee
#                         ,receive_pay_fee
#                         ,pick_finance_id
#                         ,pick_finance_code
#                         ,pick_finance_name
#                         ,dispatch_finance_code
#                         ,dispatch_finance_name
#                         ,express_type_id
#                         ,express_type_code
#                         ,express_type_name
#                         ,insured
#                         ,insured_amount
#                         ,insured_fee
#                         ,cod_need
#                         ,cod_money
#                         ,cod_fee
#                         ,settlement_id
#                         ,settlement_code
#                         ,settlement_name
#                         ,paid_mode_code
#                         ,paid_mode_name
#                         ,receiver_name
#                         ,receiver_company
#                         ,receiver_country_id
#                         ,receiver_country_name
#                         ,receiver_province_id
#                         ,receiver_province_name
#                         ,receiver_city_id
#                         ,receiver_city_name
#                         ,receiver_area_id
#                         ,receiver_area_name
#                         ,receiver_township
#                         ,receiver_street
#                         ,receiver_detailed_address
#                         ,receiver_postal_code
#                         ,receiver_email
#                         ,destination_id
#                         ,destination_code
#                         ,destination_name
#                         ,receiver_sorting_code
#                         ,input_time
#                         ,delivery_time
#                         ,input_staff_code
#                         ,input_staff_name
#                         ,input_network_code
#                         ,input_network_name
#                         ,coupon_code
#                         ,coupon_amount
#                         ,remarks
#                         ,prints_number
#                         ,bill_no
#                         ,is_cash
#                         ,is_cod_receive
#                         ,currency_code
#                         ,currency_name
#                         ,settlement_weight
#                         ,customer_id
#                         ,order_source_code
#                         ,last_update_time
#                         ,is_delete
#                         ,is_plaintext
#                         ,refund_time
#                         ,input_staff_by
#                         ,real_name
#                         ,id_no_type
#                         ,sex
#                         ,distribute_finance_id
#                         ,distribute_finance_code
#                         ,distribute_finance_name
#                         ,package_collect_weight
#                         ,package_receipt_weight
#                         ,package_arrival_weight
#                         ,package_inside_charge_weight
#                         ,is_distribute_scan
#                         ,is_arrival_scan
#                         ,waybill_weight
#                         ,miss_flag
#                         ,is_business
#                         ,is_receive
#                         ,customer_network_code
#                         ,customer_network_name
#                         ,customer_type
#                         ,calculate_fee_desc
#                         ,calculate_fee_code
#                         ,printer_counterfoil
#                         ,quotetype_code
#                         ,receipt_fee
#                         ,package_center_arrival_weight
#                         )
#                  )
#                  WITH BROKER '{{{{ var.json.doris_brokers | random_choice }}}}'
#                  PROPERTIES ('timeout'='{timeout}', 'max_filter_ratio'='0.0')""",
#     poke_sql=f"SHOW LOAD FROM jms_ods WHERE label = '{label}' ORDER BY CreateTime DESC LIMIT 1",
#     sql_on_kill=f"CANCEL LOAD FROM jms_ods WHERE LABEL = '{label}'",
#     success=lambda r: r[2] == 'FINISHED',
#     failure=lambda r: (r[2] is not None and r[2] == 'CANCELLED', str(r[7])),
#     poke_interval=60,
#     execution_timeout=timedelta(seconds=timeout + 120), )
#
# doris_jms_ods__yl_oms_oms_waybill << \
# [jms_ods__yl_oms_oms_waybill,]
